{extend name="base" /} {block name="body"}
<link rel="stylesheet" href="__ADMIN__/css/template.css">
<div class="admin-main">
    <div class="layui-field-box layui-form">

        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <li class="layui-this">管理模板</li>
                <li><a href="javascript:;" id="onlineTemp">在线模板</a></li>
            </ul>
        </div>

        <div id="theme" style="padding:0 20px">
            <div class="themeList" style="padding-top: 10px">
                <h2 style="color: #999">当前启用的模板</h2>
                <dl>
                    <p><a href="https://www.laysns.com/app_detail/{$used_tpl.app_id}.html" title="点击可查看模板在官网的详情介绍" target="_blank"><img src="__ROOT__{$used_tpl.image}"></a></p>
                    <dt>{$used_tpl.name} {$used_tpl.version}</dt>
                    <dd>作者：<a href="https://www.laysns.com/developer/{$used_tpl.developer_id}.html" title="点击可查看作者个人主页" target="_blank">{$used_tpl.author}</a></dd>
                    <dd>
                    <dd  style="height:40px;overflow: hidden;">
                        简介：{$used_tpl.description}
                    </dd>
                </dl>
            </div>

            <div class="themeList">
                <h2>可用模板</h2>
                {foreach name="theme_list" item="vo"}
                <dl>
                    <p><a target="_blank" href="https://www.laysns.com/app_detail/{$vo.app_id}.html"><img src="__ROOT__{$vo.image}"></a></p>
                    <dt>{$vo.name} {$vo.version}</dt>
                    <dd>作者：{$vo.author}</dd>
                    <dd  style="height:40px;overflow: hidden;">
                        简介：{$vo.description}
                    </dd>
                    <dd class="btnList"><a href="javascript:;" data-url="{:url('system/deltpl',array('tpl_name'=>$vo.tpl_name))}" class="del">删除</a> <span><a href="javascript:;" data-url="{:url('system/usetpl',array('tpl_name'=>$vo.tpl_name))}" class='usetpl'>启用</a> <a target="_blank" href="{$vo.demo_link}">演示站</a></span></dd>
                </dl>
                {/foreach}
            </div>

        </div>
    </div>

</div>
{/block} {block name="script"}
<script>
    layui.use(['layer', 'jquery', 'form'], function() {
        var layer = layui.layer,
            form = layui.form,
            jq = layui.jquery;

        jq('#onlineTemp').click(function() {
            layer.alert('萤火虫大神即将发布新作！敬请期待！');
        });
        jq('.usetpl').click(function() {

            var url = jq(this).data('url');
            jq.getJSON(url, function(data) {
                if (data.code == 200) {
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 1000
                    }, function() {
                        location.reload();
                    });
                } else {

                    layer.msg(data.msg, {
                        icon: 2,
                        anim: 6,
                        time: 1000
                    });
                }
            });

        });
        jq('.del').click(function() {

            var url = jq(this).data('url');
            jq.getJSON(url, function(data) {
                if (data.code == 200) {
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 1000
                    }, function() {
                        location.reload();
                    });
                } else {

                    layer.msg(data.msg, {
                        icon: 2,
                        anim: 6,
                        time: 1000
                    });
                }
            });


        });



    });
</script>
{/block}